a = eval(input())
b = eval(input())
m = eval(input())
print(pow(a,b))
print(pow(a,b)%m)